function t = ms2tex(mean_val, std_val, sigs, sigs2, prefix)
  ismax = 1;

if ~isempty(sigs2)
sigs(isnan(sigs)) = 0; % failed to reject a=b, nan means a = b, of course sigs = 0
sigs2(isnan(sigs2)) = 1.0;
end
if isempty(prefix)
    prefix='Average';
end    
n = 10;
n
t = prefix;
if ismax
    [~, idx] = max(mean_val);
else
    [~, idx] = min(mean_val);
end
for i1 = 1:n
    if isempty(sigs2)&&~isempty(std_val)
        if i1 == idx
            t = [t, '& \tabincell{c}{ \textbf{', num2str(mean_val(i1) * 100, '%4.2f'), '} \\ \textbf{$\pm$ ', num2str(std_val(i1) * 100, '%4.2e'), '}} '];
        else
            t = [t, '& \tabincell{c}{ ', num2str(mean_val(i1) * 100, '%4.2f'), ' \\ $\pm$ ', num2str(std_val(i1) * 100, '%4.2e'), '} '];
        end
        
    elseif isempty(std_val)&&isempty(sigs2)    
        if i1 == idx
            t = [t, '& \tabincell{c}{ \textbf{', num2str(mean_val(i1) * 100, '%4.2f'), '}} '];
        else
            t = [t, '& \tabincell{c}{ ', num2str(mean_val(i1) * 100, '%4.2f'),'}'];
        end
        
    else
        if sigs(i1) == 0&&sigs2(i1)== 1
            t = [t, '& \tabincell{c}{ \textbf{', num2str(mean_val(i1) * 100, '%4.2f'),'} \\ \textbf{$\pm$ ', num2str(std_val(i1) * 100), ' } \\ \textbf{', num2str(sigs2(i1), '%4.2e'), ' }} '];
        elseif sigs2(i1)>=0.05
             t = [t, '& \tabincell{c}{ \textbf{', num2str(mean_val(i1) * 100, '%4.2f'), '} \\ \textbf{$\pm$ ', num2str(std_val(i1) * 100) , '} \\ \textbf{', num2str(sigs2(i1), '%4.2e'), ' }} '];
        else
            t = [t, '& \tabincell{c}{ ', num2str(mean_val(i1) * 100, '%4.2f'), ' \\ $\pm$ ', num2str(std_val(i1) * 100), ' \\', num2str(sigs2(i1), '%4.2e'), ' } '];
        end
    end
    
end
t = [t, '\\ \hline'];
end